package com.yishan.security.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: yishan
 * @Date: 2022/8/26 11:28
 **/
@RestController
@RequestMapping("redis")
public class RedisDemoController {

    @Autowired
    RedisTemplate redisTemplate;

    @RequestMapping("save")
    public String save(String key, String value) {
        ValueOperations ops = redisTemplate.opsForValue();
        ops.set(key, value);
        return "save success !";
    }


    @RequestMapping("get")
    public Object get(String key) {
        ValueOperations ops = redisTemplate.opsForValue();
        Object object = ops.get(key);
        return object;
    }

}
